package com.cryptoneedle.garden.repository.garden.ads;


import com.bubbles.engine.data.core.repository.BaseRepository;
import com.cryptoneedle.garden.entity.garden.ads.AdsColumn;
import com.cryptoneedle.garden.key.ColumnKey;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>description: Ods-SourceColumn </p>
 *
 * @author CryptoNeedle
 * @date 2025-09-25
 */
@Repository
public interface AdsColumnRepository extends BaseRepository<AdsColumn, ColumnKey> {

    @Query("FROM AdsColumn ORDER BY catalogName, databaseName, tableName, ordinalPosition")
    List<AdsColumn> adsColumns();

    @Query("""
             FROM AdsColumn
            WHERE catalogName = :catalogName
            ORDER BY catalogName, databaseName, tableName
            """)
    List<AdsColumn> adsColumns(String catalogName);

    @Query("""
             FROM AdsColumn
            WHERE catalogName = :catalogName
              AND databaseName = :databaseName
            ORDER BY catalogName, databaseName, tableName
            """)
    List<AdsColumn> adsColumns(String catalogName, String databaseName);

    @Query("""
             FROM AdsColumn
            WHERE catalogName = :catalogName
              AND databaseName = :databaseName
              AND tableName = :tableName
            ORDER BY catalogName, databaseName, tableName
            """)
    List<AdsColumn> adsColumns(String catalogName, String databaseName, String tableName);
}